package com.lonely.web.controller.order;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.lonely.common.core.domain.TimeLine;
import com.lonely.common.core.domain.api.R;
import com.lonely.goods.domain.dto.log.AddNotesDTO;
import com.lonely.goods.domain.vo.log.OrderNoteLogVO;
import com.lonely.order.service.IOrderLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: 黄志标
 * @date: 2025/6/24 9:23
 * @description: 订单日志请求处理器
 */
@RestController
@RequestMapping("/orderManager/orderLog")
@Api(tags = "订单管理/订单日志")
public class OrderLogController {

    @Autowired
    private IOrderLogService orderLogService;

    /**
     * 获取指定订单号的日志时间线
     *
     * @param produceOrderId
     * @return
     */
    @GetMapping("/getOrderLogTimeLine/{produceOrderId}")
    @ApiOperation(value = "获取指定订单号的日志时间线")
    @SaCheckPermission("order:followList:getOrderLogTimeLine")
    public R<List<TimeLine>> getOrderLogTimeLine(@PathVariable("produceOrderId") Long produceOrderId) {
        return R.data(this.orderLogService.getOrderLogTimeLine(produceOrderId));
    }


    /**
     * 获取指定订单的备注日志列表
     *
     * @param orderId
     * @return
     */
    @GetMapping("/getOrderNoteLogs/{orderId}")
    @ApiOperation(value = "获取指定订单的备注日志列表")
    public R<List<OrderNoteLogVO>> getOrderNoteLogs(@PathVariable("orderId") Long orderId) {
        return R.data(this.orderLogService.getOrderNoteLogs(orderId));
    }


    /**
     * 添加备注
     *
     * @param addNotes
     * @return
     */
    @PostMapping("/addNotes")
    @ApiOperation(value = "添加备注")
    public R<Boolean> addNotes(@RequestBody @Validated AddNotesDTO addNotes) {
        this.orderLogService.addNotes(addNotes);
        return R.status(true);
    }

}
